package top.xia17.plugins.fast.user.dao.entity;

import top.xia17.plugins.fast.common.database.jpa.extension.BaseUserTimeEntity;
import top.xia17.plugins.fast.common.database.jpa.extension.JpaEntity;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;

import jakarta.persistence.*;
import java.util.Set;

/**
 * 角色实体
 * @author xia17
 * @since 2021/7/29 10:18
 */
@Getter
@Setter
@NoArgsConstructor
@Entity
@Table(name = "sys_role")
@EqualsAndHashCode(of = "id", callSuper = false)
@Accessors(chain = true)
public class Role extends BaseUserTimeEntity implements JpaEntity<Long> {

    /** 角色ID */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /** 角色名 */
    private String name;

    /** 描述 */
    private String description;

    /** 权限标识 */
    private String permission;

    @ManyToMany(fetch = FetchType.LAZY)
    @JoinTable(name = "sys_roles_menus",
            joinColumns = {@JoinColumn(name = "role_id", referencedColumnName = "id")},
            inverseJoinColumns = {@JoinColumn(name = "menu_id", referencedColumnName = "id")})
    private Set<Menu> menus;


}
